package Common
{
	import flash.events.TimerEvent;
	import flash.utils.*;
	
	public class GameTimer extends Object
	{
		private var ticker:Timer;
		private var func:Function;
		private var last:int;
		
		public function GameTimer(param1:int, param2:Function)
		{
			ticker = new Timer(param1);
			ticker.addEventListener(TimerEvent.TIMER, onTick);
			func = param2;
			last = getTimer();
			ticker.start();
		}
		
		private function onTick(event:TimerEvent) : void
		{
			var now:int = getTimer();
			func(now - last);
			last = now;
		}
		
		public function stop():void
		{
			ticker.stop();
		}
		
	}

}